package legumes.shared.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Id;

public class Customer implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final String ROOT_ID = "root@root.fr";
	/**
	 * This password works whoever the remote client. By default, the root user
	 * has this password.
	 */
	public static final String SUPER_PASSWORD = "wkjfff";

	
	private long creationDate = new Date().getTime();
	private long lastConnectionDate = -1;
	private String name = "";
	@Id private String email;
	private String password = "";
	private String roles = CustomerRole.CUSTOMER.toString();
	private String lastConnectionAddr;
	private long activationAccountDate = -1;
	private long activationUuid;
	
	public String getLastConnectionAddr() {
		return lastConnectionAddr;
	}

	public void setLastConnectionAddr(String lastConnectionAddr_) {
		lastConnectionAddr = lastConnectionAddr_;
	}

	public String getRoles() {
		return roles;
	}

	public CustomerRole getRolesAsEnum() {
		return CustomerRole.valueOf(getRoles());
	}

	public void setRoles(CustomerRole role_) {
		setRoles(role_.toString());
	}

	public void setRoles(String toStringCustomerRole_) {
		roles = toStringCustomerRole_;
	}

	public Customer() {
	}

	public long getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(long creationDate) {
		this.creationDate = creationDate;
	}

	public long getLastConnectionDate() {
		return lastConnectionDate;
	}

	public void setLastConnectionDate(long lastConnectionDate) {
		this.lastConnectionDate = lastConnectionDate;
	}

	@Override
	public String toString() {
		return getEmail();
	}

	public String toFullString() {
		return "[Customer email=" + email + " name=" + getName() + " password="
				+ getPassword() + " creationDate=" + getCreationDate()
				+ " lastConnectionDate" + getLastConnectionDate() + "]";
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public long getActivationAccountDate() {
		return activationAccountDate;
	}

	public void setActivationAccountDate(long activationAccountDate) {
		this.activationAccountDate = activationAccountDate;
	}
	
	public boolean isAccountActivated(){
		return activationAccountDate>0;
	}

	public long getActivationUuid() {
		return activationUuid;
	}

	public void setActivationUuid(long activationUuid) {
		this.activationUuid = activationUuid;
	}
	
}
